<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Demo.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <title>铁路运输登陆界面</title>
  </head>
  
  <body style=background-image:url(18.jpg);>
   <center>
   <h1><font color="red">12593铁路运输管理员添加界面</font></h1>
   <hr/>
   <br/>
   <br/>
   <%
   request.setCharacterEncoding("utf-8") ;
   int leval = (Integer)session.getAttribute("leval");
   if(leval==1) {
   if(request.getAttribute("err")!=null){
		%>
		<h2><%=request.getAttribute("err")%></h2>    
		<%
		  }
		%>
   <script language="javaScript">
    function login(){
    	if(document.person.id.value==""){
    		alert("用户名不能为空");
    		document.person.id.focus();
    		return false;
    	}
    	if(document.person.password.value=="")
		{
			 alert("密码不能为空");
			document.person.password.focus();
			return false;
		}
    	if(document.person.id.value.length > 10){
    		alert("用户名长度不能大于10");
    		document.person.id.focus();
    		return false;
    	}
    	if(document.person.password.value.length > 15){
    		alert("请输入长度小于15的密码");
    		document.person.password.focus();
    		return false;
    	}
    	if(document.person.name.value=="") {
			 alert("用户姓名不能为空");
			document.person.name.focus();
			return false;
		}
    	
    	if(document.person.name.value.length > 10){
    		alert("用户姓名的长度不能大于10");
    		document.person.name.focus();
    		return false;
    	}
    		if(document.person.sex.value=="")
		{
			 alert("性别栏不能为空");
			document.person.sex.focus();
			return false;
		}
    		if(document.person.phone.value=="")
		{
			 alert("联系电话不能为空");
			document.person.phone.focus();
			return false;
		}
    	if(document.person.phone.value.length > 11)
    	{
    		alert("联系电话长度长度不能大于11");
    		document.person.phone.focus();
    		return false;
        }
    		if(document.person.email.value=="")
		{
			 alert("用户邮箱不能为空");
			document.person.email.focus();
			return false;
		}
    	if(document.person.email.value.length > 18)
    	{
    		alert("邮箱的长度不能大于18");
    		document.person.email.focus();
    		return false;
    	}
    	return true;
    }
    </script>  
    <form action="admin" method="post" onsubmit="return login()">
    <table>
      <tr>
		<td colspan="2"><h1>管理员添加</h1> </td>
	  </tr>
      <tr>
        <td>管理员账号：</td>
        <td><input type="text" name="id"></td>
      </tr>
      <tr>
        <td>管理员密码：</td>
        <td><input type="password" name="password"></td>
      </tr>
      <tr>
        <td>管理员昵称：</td>
        <td><input type="text" name="name"></td>
      </tr>
      <tr>
        <td>管理员级别：</td>
        <td><input type="checkbox" name="leval" value=2>二级管理员</td>
	  <tr>
	    <td></td>
	    <td><input type="checkbox" name="leval" value=3>三级管理员</td>
      </tr>
      <tr>
		<td colspan="2">
		    <input type="hidden" name="status" value="addAdmin">
			<input type="submit" value="提交">
			<input type="reset" value="重置">
		</td>
	  </tr>
	  <tr>
	     <td  colspan="2"><a href = "AdminCtrl.jsp"><h1>返回主界面</h1></a></td>
	  </tr>
    </table>
    </form>
    <%
        }else{
        response.setHeader("refresh","2;url=AdminCtrl.jsp");
    %>
        只有一级管理员才有添加管理员的权利!!!
        两秒后自动跳转到主页面！！！<br>
	   如果没有跳转，请点击<a href="AdminCtrl.jsp">这里</a>!!!<br>
    <%  
      }
    %>
   </center>
  </body>
</html>
